/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "AdherentSoldeCompte")
@NamedQueries({
    @NamedQuery(name = "AdherentSoldeCompte.findAll", query = "SELECT a FROM AdherentSoldeCompte a"),
    @NamedQuery(name = "AdherentSoldeCompte.findByNoCarte", query = "SELECT a FROM AdherentSoldeCompte a WHERE a.adherentSoldeComptePK.noCarte = :noCarte"),
    @NamedQuery(name = "AdherentSoldeCompte.findBySoldeCompte", query = "SELECT a FROM AdherentSoldeCompte a WHERE a.adherentSoldeComptePK.soldeCompte = :soldeCompte")})
public class AdherentSoldeCompte implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AdherentSoldeComptePK adherentSoldeComptePK;
    @JoinColumn(name = "NoCarte", referencedColumnName = "NoCarte", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Adherent adherent;

    public AdherentSoldeCompte() {
    }

    public AdherentSoldeCompte(AdherentSoldeComptePK adherentSoldeComptePK) {
        this.adherentSoldeComptePK = adherentSoldeComptePK;
    }

    public AdherentSoldeCompte(int noCarte, int soldeCompte) {
        this.adherentSoldeComptePK = new AdherentSoldeComptePK(noCarte, soldeCompte);
    }

    public AdherentSoldeComptePK getAdherentSoldeComptePK() {
        return adherentSoldeComptePK;
    }

    public void setAdherentSoldeComptePK(AdherentSoldeComptePK adherentSoldeComptePK) {
        this.adherentSoldeComptePK = adherentSoldeComptePK;
    }

    public Adherent getAdherent() {
        return adherent;
    }

    public void setAdherent(Adherent adherent) {
        this.adherent = adherent;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (adherentSoldeComptePK != null ? adherentSoldeComptePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AdherentSoldeCompte)) {
            return false;
        }
        AdherentSoldeCompte other = (AdherentSoldeCompte) object;
        if ((this.adherentSoldeComptePK == null && other.adherentSoldeComptePK != null) || (this.adherentSoldeComptePK != null && !this.adherentSoldeComptePK.equals(other.adherentSoldeComptePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "eu.fsiebert.polytech.db.mediatheque.entity.AdherentSoldeCompte[ adherentSoldeComptePK=" + adherentSoldeComptePK + " ]";
    }
    
}
